<?php

namespace System\Library;

class Config
{

    private static function import($configDir)
    {   
        $_arr_new = [];
        foreach (glob($configDir . '/*.ini.php') as $start_file) {
            $config = [];
            $config = require $start_file;
            array_push($_arr_new,$config);
        }
        return $_arr_new;
    }

    /**
     * 根据Key获取配置文件
     *
     * @param unknown $key            
     */
    public static function get($key = '')
    {   
        $staticConfig = self::import(ROOT.'Application/Config');
        if (empty($key)) {
            return self::$staticConfig;
        }
        
        $config = [];
        foreach($staticConfig as $v){
            $keyName = explode('.', $key);
            if(isset($v[$keyName[0]][$keyName[1]])){
                $config = $v[$keyName[0]][$keyName[1]];
                break;
            }
        }
       
        return $config;
    }


   
}
